﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DataAccessLogic;

namespace BusinessLogic
{
    public class Email : Table
    {
        #region Fields
        private EmailType _emailAddressType;
        private string _emailAddress;
        private bool _isPrimary;
        private bool _isActive;
        #endregion

        #region Methods
        public static Email GetPrimaryByConstituentID(Guid constituentID)
        {
            return DataAccess.Email_DA.GetPrimaryByConstituentID(constituentID);
        }

        public static Email GetByConstituentID(Guid constituentID)
        {
            return DataAccess.Email_DA.GetByConstituentID(constituentID);
        }

        public static List<Email> GetAllByConstituentID(Guid constituentID)
        {
            return DataAccess.Email_DA.GetAllByConstituentID(constituentID);
        }
        #endregion

        #region Properties
        [SQLParameter(ColumnName = "ISACTIVE", SQLDoWhat = SQLDoWhatEnum.Get)]
        public bool IsActive
        {
            get
            {
                return _isActive;
            }
            set
            {
                _isActive = value;
            }
        }

        [SQLParameter(ColumnName = "ISPRIMARY", SQLDoWhat = SQLDoWhatEnum.Get)]
        public bool IsPrimary
        {
            get
            {
                return _isPrimary;
            }
            set
            {
                _isPrimary = value;
            }
        }

        [SQLParameter(IsClass = true)]
        public EmailType EmailAddressType
        {
            get
            {
                return _emailAddressType;
            }
            set
            {
                _emailAddressType = value;
            }
        }

        [SQLParameter(ColumnName = "EMAILADDRESS", SQLDoWhat = SQLDoWhatEnum.Get)]
        public string EmailAddress
        {
            get
            {
                return _emailAddress;
            }
            set
            {
                _emailAddress = value;
            }
        }
        #endregion


        public override DatabaseInteractionDescriptor TableInteractionDescription()
        {
            DatabaseInteractionDescriptor desc = new DatabaseInteractionDescriptor();
            desc.CreateStoredProcedure = StoredProcedures.USP_EMAILADDRESS_CREATE;
            return desc;
        }
    }
}